import {actions} from '../base';
import Vue from "vue";

let url = 'admin/api/user';

export default {
    namespaced: true,
    state: {
        all: [],
        options: {
            online: [
                {label: '离线', value: 0},
                {label: '在线', value: 1},
            ],
            flagBit: [
                {label: '锁定', value: 1},
                {label: '内部号', value: 2},
                {label: '羊毛党', value: 4},
                {label: '小号', value: 8},
                {label: '关注', value: 16},
                {label: '投诉', value: 32},
                {label: '注销', value: 64},
                {label: '审核', value: 128},
                {label: '危险', value: 256},
            ],
            realNameStatus: {
                0: '待实名',
                1: '实名中',
                2: '实名失败',
                3: '未成年',
                4: '已实名',
            }
        },
    },

    mutations: {
        // SET_ALL(state, data) {
        //     state.all = data;
        // },
    },
    actions: Object.assign(actions(url), {
        Update ({commit}, data) {
            return Vue.axios.put(`${url}/${data.userId}`, data);
        },
        UpdateFlag ({commit}, data) {
            return new Promise((resolve, reject) => {
                Vue.axios.put(url + '/flag/' + data.userId, data).then(res => {
                    return resolve(res);
                }).catch(error => {
                    return reject(error);
                });
            });
        },
        Info ({commit}, data = {}) {
            return Vue.axios.get(`${url}/info`, {
                params: data,
            });
        },
        CplUserRelation({commit}, filter) {
            return Vue.axios.get(`${url}/cpl-user-relation`, {
                params: filter,
            });
        },
        Players ({commit}, data = {}) {
            return Vue.axios.get(`${url}/players`, {
                params: data,
            });
        },
        RealName ({commit}, data = {}) {
            return Vue.axios.get(`${url}/realname`, {
                params: data,
            });
        },
        OperateLogs ({commit}, data = {}) {
            return Vue.axios.get(`${url}/operate-logs`, {
                params: data,
            });
        },
        AddBlacklist ({commit}, data = {}) {
            return Vue.axios.post(`${url}/add-blacklist`, data);
        },
        Pet ({commit}, data = {}) {
            return Vue.axes.get(`${url}/pet`, {
                params: data,
            })
        },
        Rune ({commit}, data = {}) {
            return Vue.axes.get(`${url}/rune`, {
                params: data,
            })
        },
        Prop ({commit}, data = {}) {
            return Vue.axes.get(`${url}/prop`, {
                params: data,
            })
        },
        Hero ({commit}, data = {}) {
            return Vue.axes.get(`${url}/rune`, {
                params: data,
            })
        },
        Asset ({commit}, data = {}) {
            return Vue.axios.get(`${url}/asset`, {
                params: data,
            })
        },
    }),
    getters: {}
};
